{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}个人信息{% endblock %}
{% block nav_home_active %}active{% endblock %}
{% block style %}
<link rel="stylesheet" href="{% static 'css/user_info.css' %}">
{% endblock %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-xs-8 col-xs-offset-2">
            {% if user.is_authenticated %}
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title">个人信息</h3>
                </div>
                <div class="panel-body">
                    <ul class="list-group">
                        <li class="list-group-item">
                            <span>用户名: </span>{{user_info.username}}
                        </li>
                        <li class="list-group-item">
                            <span>昵称: </span>{{user.get_nickname}}
                            <a href="{% url 'change_nickname' %}?from={{request.get_full_path}}">修改昵称</a>
                        </li>
                        <li class="list-group-item">
                            <span>邮箱: </span>
                            {% if user_info.email %}
                            {{user_info.email}}
                            {% else %}
                            未绑定邮箱,<a href="{% url 'bind_email' %}">绑定邮箱</a>
                            {% endif %}
                        </li>
                        <li class="list-group-item">
                            <span>上一次登录时间: </span>
                            {{ user_info.last_login }}
                        </li>
                        <li class="list-group-item">
                            <span><a href="{% url 'change_password' %}">修改密码</a></span>
                        </li>
                    </ul>
                </div>
            </div>
            {% else %}
            <div class="not_login">
                <p>未登录，<span id="redirect">5</span>秒后跳转到首页...</p>
            </div>
            <script>
                var t = 4
                var t1 = setInterval(() => {
                    $("#redirect").text(t)
                    t -= 1
                }, 1000);
                setTimeout(function () {
                    clearInterval(t1)
                    window.location.href = '/'
                }, 5000)
            </script>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}
